package com.zzy.algorithm.sort;

/**
 * 选择排序
 */
public class Q26_SelectionSort {

    public static int[] nums = new int[]{5,7,1,2,8,9,3};

    public static void main(String[] args) {
        selectionSort(nums);
        for(int x : nums){
            System.out.println(x);
        }
    }



    private static void selectionSort(int[] nums){
        for(int i = 0 ; i < nums.length ;i++){
            int minIndex = i;
            for(int j = i + 1 ; j < nums.length ; j++){
                if(nums[j] < nums[minIndex]){
                    minIndex = j;
                }
            }
            int tmp = nums[i];
            nums[i] = nums[minIndex];
            nums[minIndex] = tmp;
        }
    }



}
